<?php


abstract class BaseRingtoneSynchronize extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $ring_id;


	
	protected $sys_date;


	
	protected $ring_name;


	
	protected $ring_link;


	
	protected $creator_name;


	
	protected $composer_name;


	
	protected $rbt_code;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getRingId()
	{

		return $this->ring_id;
	}

	
	public function getSysDate($format = 'Y-m-d H:i:s')
	{

		if ($this->sys_date === null || $this->sys_date === '') {
			return null;
		} elseif (!is_int($this->sys_date)) {
						$ts = strtotime($this->sys_date);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [sys_date] as date/time value: " . var_export($this->sys_date, true));
			}
		} else {
			$ts = $this->sys_date;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getRingName()
	{

		return $this->ring_name;
	}

	
	public function getRingLink()
	{

		return $this->ring_link;
	}

	
	public function getCreatorName()
	{

		return $this->creator_name;
	}

	
	public function getComposerName()
	{

		return $this->composer_name;
	}

	
	public function getRbtCode()
	{

		return $this->rbt_code;
	}

	
	public function setRingId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ring_id !== $v) {
			$this->ring_id = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::RING_ID;
		}

	} 
	
	public function setSysDate($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [sys_date] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->sys_date !== $ts) {
			$this->sys_date = $ts;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::SYS_DATE;
		}

	} 
	
	public function setRingName($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->ring_name !== $v) {
			$this->ring_name = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::RING_NAME;
		}

	} 
	
	public function setRingLink($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->ring_link !== $v) {
			$this->ring_link = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::RING_LINK;
		}

	} 
	
	public function setCreatorName($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->creator_name !== $v) {
			$this->creator_name = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::CREATOR_NAME;
		}

	} 
	
	public function setComposerName($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->composer_name !== $v) {
			$this->composer_name = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::COMPOSER_NAME;
		}

	} 
	
	public function setRbtCode($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->rbt_code !== $v) {
			$this->rbt_code = $v;
			$this->modifiedColumns[] = RingtoneSynchronizePeer::RBT_CODE;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->ring_id = $rs->getInt($startcol + 0);

			$this->sys_date = $rs->getTimestamp($startcol + 1, null);

			$this->ring_name = $rs->getString($startcol + 2);

			$this->ring_link = $rs->getString($startcol + 3);

			$this->creator_name = $rs->getString($startcol + 4);

			$this->composer_name = $rs->getString($startcol + 5);

			$this->rbt_code = $rs->getString($startcol + 6);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 7; 
		} catch (Exception $e) {
			throw new PropelException("Error populating RingtoneSynchronize object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneSynchronizePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			RingtoneSynchronizePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtoneSynchronizePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = RingtoneSynchronizePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setNew(false);
				} else {
					$affectedRows += RingtoneSynchronizePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = RingtoneSynchronizePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneSynchronizePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getRingId();
				break;
			case 1:
				return $this->getSysDate();
				break;
			case 2:
				return $this->getRingName();
				break;
			case 3:
				return $this->getRingLink();
				break;
			case 4:
				return $this->getCreatorName();
				break;
			case 5:
				return $this->getComposerName();
				break;
			case 6:
				return $this->getRbtCode();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneSynchronizePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getRingId(),
			$keys[1] => $this->getSysDate(),
			$keys[2] => $this->getRingName(),
			$keys[3] => $this->getRingLink(),
			$keys[4] => $this->getCreatorName(),
			$keys[5] => $this->getComposerName(),
			$keys[6] => $this->getRbtCode(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtoneSynchronizePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setRingId($value);
				break;
			case 1:
				$this->setSysDate($value);
				break;
			case 2:
				$this->setRingName($value);
				break;
			case 3:
				$this->setRingLink($value);
				break;
			case 4:
				$this->setCreatorName($value);
				break;
			case 5:
				$this->setComposerName($value);
				break;
			case 6:
				$this->setRbtCode($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtoneSynchronizePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setRingId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setSysDate($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setRingName($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setRingLink($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setCreatorName($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setComposerName($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setRbtCode($arr[$keys[6]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(RingtoneSynchronizePeer::DATABASE_NAME);

		if ($this->isColumnModified(RingtoneSynchronizePeer::RING_ID)) $criteria->add(RingtoneSynchronizePeer::RING_ID, $this->ring_id);
		if ($this->isColumnModified(RingtoneSynchronizePeer::SYS_DATE)) $criteria->add(RingtoneSynchronizePeer::SYS_DATE, $this->sys_date);
		if ($this->isColumnModified(RingtoneSynchronizePeer::RING_NAME)) $criteria->add(RingtoneSynchronizePeer::RING_NAME, $this->ring_name);
		if ($this->isColumnModified(RingtoneSynchronizePeer::RING_LINK)) $criteria->add(RingtoneSynchronizePeer::RING_LINK, $this->ring_link);
		if ($this->isColumnModified(RingtoneSynchronizePeer::CREATOR_NAME)) $criteria->add(RingtoneSynchronizePeer::CREATOR_NAME, $this->creator_name);
		if ($this->isColumnModified(RingtoneSynchronizePeer::COMPOSER_NAME)) $criteria->add(RingtoneSynchronizePeer::COMPOSER_NAME, $this->composer_name);
		if ($this->isColumnModified(RingtoneSynchronizePeer::RBT_CODE)) $criteria->add(RingtoneSynchronizePeer::RBT_CODE, $this->rbt_code);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(RingtoneSynchronizePeer::DATABASE_NAME);

		$criteria->add(RingtoneSynchronizePeer::RING_ID, $this->ring_id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getRingId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setRingId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setSysDate($this->sys_date);

		$copyObj->setRingName($this->ring_name);

		$copyObj->setRingLink($this->ring_link);

		$copyObj->setCreatorName($this->creator_name);

		$copyObj->setComposerName($this->composer_name);

		$copyObj->setRbtCode($this->rbt_code);


		$copyObj->setNew(true);

		$copyObj->setRingId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new RingtoneSynchronizePeer();
		}
		return self::$peer;
	}

} 